package com.slunk.accessors;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Sprite;
import aurelienribon.tweenengine.TweenAccessor;

public class SpriteAccessor implements TweenAccessor <Sprite>{
	
	private static final int ROTATION 		= 1;
	public static final int POSITION_X 		= 2;
    public static final int POSITION_Y 		= 3;
    public static final int POSITION_XY 	= 4;
    public static final int FADE 			= 5;

	@Override
	public int getValues(Sprite target, int tweenType, float[] returnValues) {
		
	    switch (tweenType) {
	        case ROTATION:
	            returnValues[0] = target.getRotation();
	            return 1;
	        case POSITION_X:
	        	returnValues[0] = target.getX();
	        	return 1;
	        case POSITION_Y:
	        	returnValues[0] = target.getY();
	        	return 1;
	        case POSITION_XY:
	        	returnValues[0] = target.getX();
	        	returnValues[1] = target.getY();
	        	return 2;
	        case FADE:
	        	returnValues[0] = target.getColor().a;
	        	return 1;
	    }
		return -1;
	}

	@Override
	public void setValues(Sprite target, int tweenType, float[] arg2) {
		// TODO Auto-generated method stub
		switch (tweenType) {
	        case POSITION_X: target.setX(arg2[0]); break;
	        case POSITION_Y: target.setY(arg2[0]); break;
	        case POSITION_XY:
	        	target.setPosition(arg2[0], arg2[1]);
	            break;
	        case FADE: 
	        	Color oldColor = target.getColor();
	        	Color transformedColor = new Color(oldColor.r,oldColor.g,oldColor.b,arg2[0]);
	        	target.setColor(transformedColor);
	        	break;
	        default: assert false; break;
		}
	}
}
